/*
 * Copyright (c) 2017,安徽皖通科技股份有限公司 All rights reserved.
 */

package com.wttech.dzzf.process.run;

import com.wttech.dzzf.process.service.backup.BackupObuIdInfoService;
import com.wttech.dzzf.process.service.blacklist.BlackListCreatorService;
import com.wttech.dzzf.process.service.blacklist.GenerateBlObuInfosService;
import com.wttech.dzzf.process.service.blacklist.RecordBlObuInfosService;
import com.wttech.dzzf.process.service.correct.CorrectErrorOrgInfos;
import com.wttech.dzzf.process.service.correct.CorrectErrorUserId;
import com.wttech.dzzf.process.service.fill.FillFundAccountInfoService;
import com.wttech.dzzf.process.service.fill.FillMissingInfosService;
import com.wttech.dzzf.process.service.govern.DataGovernService;
import com.wttech.dzzf.process.service.initilize.DataInitilizingService;
import com.wttech.dzzf.process.service.initilize.SubDataInitilizingService;
import com.wttech.dzzf.process.service.initilize.SubFundAccountProcessService;
import com.wttech.dzzf.process.service.migrate.ImportHisDataService;
import com.wttech.dzzf.process.service.migrate.ImportRepeatHisDataService;
import com.wttech.dzzf.process.service.migrate.MergeUserInfoService;
import com.wttech.dzzf.process.service.test.CbcBankDataCheckService;
import com.wttech.dzzf.process.service.upload.UploadDataAgainService;
import com.wttech.dzzf.process.service.upload.UploadProductDataService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Scanner;

/**
 * 程序运行入口
 *
 * @author MaShibo
 * @date 2017/12/5.
 */
public class InitilizingRunService {

	private static final Logger LOGGER = LoggerFactory.getLogger(InitilizingRunService.class);

	public static void main(String[] args) {
		LOGGER.info("请选择要执行的操作：");
		LOGGER.info("1. 数据初始化生成");
		LOGGER.info("2. 测试银行数据");
		LOGGER.info("3. 处理银行接入数据");
		LOGGER.info("4. 数据治理");
		LOGGER.info("5. 上传数据");
		LOGGER.info("6. 数据重传");
		LOGGER.info("7. 填充数据");
		LOGGER.info("8. 处理待接入数据");
		LOGGER.info("9. 合并重复账户信息");
		LOGGER.info("10.填充缺失的资金账户信息");
		LOGGER.info("11. 分阶段生成卡片、车辆和OBU初始化信息");
		LOGGER.info("12. 合并个人客户信息");
		LOGGER.info("13. 更新卡片类型");
		LOGGER.info("14. 纠正组织机构信息");
		LOGGER.info("15. 生成黑名单信息");
		LOGGER.info("16. 记录未上传的OBU信息");
		LOGGER.info("17. 寻找未上传OBU的USERID");
		LOGGER.info("18. 备份待更新的OBU信息");
		Scanner sc = new Scanner(System.in);
		String select = sc.next();
		int selectVal;
		try {
			selectVal = Integer.parseInt(select);
		} catch (NumberFormatException e) {
			LOGGER.error("非法输入");
			return;
		}
		switch (selectVal) {
			case 1:
				DataInitilizingService.main(new String[]{});
				break;
			case 2:
				CbcBankDataCheckService.main(new String[]{});
				break;
			case 3:
				ImportHisDataService.main(new String[]{});
				break;
			case 4:
				DataGovernService.main(new String[]{});
				break;
			case 5:
				LOGGER.info("请输入要上传的数据类型，用逗号分隔");
				select = sc.next();
				UploadProductDataService.main(StringUtils.split(select, ", "));
				break;
			case 6:
				LOGGER.info("请输入要重传的数据类型");
				select = sc.next();
				UploadDataAgainService.main(new String[]{select});
				break;
			case 7:
				LOGGER.info("填充数据");
				FillMissingInfosService.main(new String[]{});
				break;
			case 8:
				ImportHisDataService.main(new String[]{});
				break;
			case 9:
				ImportRepeatHisDataService.main(new String[]{});
				break;
			case 10:
				FillFundAccountInfoService.main(new String[]{});
				break;
			case 11:
				LOGGER.info("请分别输入1、2、3表示3个时间阶段：");
				select = sc.next();
				try {
					Integer.valueOf(select);
				} catch (NumberFormatException e) {
					LOGGER.error(e.getMessage(), e);
					return;
				}
				SubFundAccountProcessService.main(new String[]{select});
				break;
			case 12:
				MergeUserInfoService.main(new String[]{});
				break;
			case 13:
				LOGGER.info("请分别输入1、2、3表示3个阶段：");
				select = sc.next();
				CorrectErrorUserId.main(new String[]{select});
				break;
			case 14:
				LOGGER.info("纠正组织机构信息");
				CorrectErrorOrgInfos.main(new String[]{});
				break;
			case 15:
				LOGGER.info("已选择，生成黑名单临时数据");
				BlackListCreatorService.main(new String[]{});
				break;
			case 16:
				RecordBlObuInfosService.main(new String[]{});
				break;
			case 17:
				GenerateBlObuInfosService.main(new String[]{});
				break;
			case 18:
				BackupObuIdInfoService.main(new String[]{});
				break;
			default:
				LOGGER.info("无此操作！");
				break;
		}
	}
}
